package com.xflib.shardingsphere.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 订单实体类
 *
 * @author Jiahai
 */
@Accessors(chain = true)
@Entity
@Table(name = "t_order")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@DynamicUpdate
@DynamicInsert
public class Order implements Serializable {
    // 字段常量
    public static final String ORDER_ID = "orderId";
    public static final String USER_ID = "userId";
    public static final String ORDER_NAME = "orderName";
    public static final String CREATE_TIME = "createTime";

    /**
     * 订单ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long orderId;

    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 订单名称
     */
    private String orderName;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(updatable=false)
    private Date createTime;
}
